// 模拟数据生成器

// 生成用户模拟数据
export const generateUsers = (count: number) => {
  return Array.from({ length: count }, (_, index) => ({
    id: index + 1,
    username: `user${index + 1}`,
    email: `user${index + 1}@example.com`,
    phone: `1381234567${index % 10}`,
    roleId: Math.floor(Math.random() * 3) + 1,
    roleName: ['管理员', '编辑', '普通用户'][Math.floor(Math.random() * 3)],
    status: Math.random() > 0.2,
    createTime: new Date(Date.now() - Math.floor(Math.random() * 30) * 24 * 60 * 60 * 1000).toLocaleString('zh-CN')
  }))
}

// 生成角色模拟数据
export const generateRoles = () => {
  return [
    { id: 1, name: '管理员', description: '系统管理员，拥有所有权限', createTime: '2023-01-01 10:00:00' },
    { id: 2, name: '编辑', description: '内容编辑，可以管理内容', createTime: '2023-01-02 14:30:00' },
    { id: 3, name: '运营', description: '数据运营，可以查看数据', createTime: '2023-01-03 09:15:00' },
    { id: 4, name: '客服', description: '客户服务，可以查看用户信息', createTime: '2023-01-04 16:45:00' },
    { id: 5, name: '普通用户', description: '基础用户权限', createTime: '2023-01-05 11:20:00' }
  ]
}

// 生成权限树模拟数据
export const generatePermissionTree = () => {
  return [
    {
      id: 1,
      name: '系统管理',
      code: 'system',
      description: '系统管理模块',
      isMenu: true,
      path: '/system',
      icon: 'el-icon-setting',
      children: [
        {
          id: 101,
          name: '用户管理',
          code: 'system:user',
          description: '用户管理功能',
          isMenu: true,
          path: '/user',
          icon: 'el-icon-user'
        },
        {
          id: 102,
          name: '角色管理',
          code: 'system:role',
          description: '角色管理功能',
          isMenu: true,
          path: '/role',
          icon: 'el-icon-user-solid'
        },
        {
          id: 103,
          name: '权限管理',
          code: 'system:permission',
          description: '权限管理功能',
          isMenu: true,
          path: '/permission',
          icon: 'el-icon-lock'
        }
      ]
    },
    {
      id: 2,
      name: '内容管理',
      code: 'content',
      description: '内容管理模块',
      isMenu: true,
      path: '/content',
      icon: 'el-icon-document',
      children: [
        {
          id: 201,
          name: '文章管理',
          code: 'content:article',
          description: '文章管理功能',
          isMenu: true,
          path: '/article',
          icon: 'el-icon-document-checked'
        },
        {
          id: 202,
          name: '分类管理',
          code: 'content:category',
          description: '分类管理功能',
          isMenu: true,
          path: '/category',
          icon: 'el-icon-menu'
        }
      ]
    },
    {
      id: 3,
      name: '数据统计',
      code: 'statistics',
      description: '数据统计模块',
      isMenu: true,
      path: '/statistics',
      icon: 'el-icon-pie-chart',
      children: [
        {
          id: 301,
          name: '用户统计',
          code: 'statistics:user',
          description: '用户统计功能',
          isMenu: true,
          path: '/user-statistics',
          icon: 'el-icon-user'
        },
        {
          id: 302,
          name: '内容统计',
          code: 'statistics:content',
          description: '内容统计功能',
          isMenu: true,
          path: '/content-statistics',
          icon: 'el-icon-document'
        }
      ]
    }
  ]
}

// 生成仪表盘统计数据
export const generateDashboardStats = () => {
  return {
    userCount: 100,
    roleCount: 10,
    permissionCount: 50,
    userGrowth: [
      { month: '1月', count: 10 },
      { month: '2月', count: 15 },
      { month: '3月', count: 20 },
      { month: '4月', count: 18 },
      { month: '5月', count: 25 },
      { month: '6月', count: 30 }
    ],
    roleDistribution: [
      { name: '管理员', value: 10 },
      { name: '编辑', value: 20 },
      { name: '运营', value: 15 },
      { name: '客服', value: 30 },
      { name: '普通用户', value: 25 }
    ]
  }
}

// 导出所有mock数据
export const mockData = {
  users: generateUsers(50),
  roles: generateRoles(),
  permissions: generatePermissionTree(),
  dashboardStats: generateDashboardStats()
}